<template>
	<view>
		<!-- 正在进行活动 -->
		<view style="width: 95%;margin: 20rpx auto;height: 500rpx;background-color: #FFFFFF;border-radius: 20rpx;">
			<view>
				<view
					style="color: green;font-size: 36rpx;font-weight: 900;border-bottom: 1rpx solid green;width: 180rpx;padding-bottom: 10rpx;padding: 20rpx;">
					正在进行
				</view>
			</view>
			<scroll-view scroll-y style="height: 400rpx;">
				<c-activity-manage-list @updateOk="updateOk" :nowStatus="1" :data="underwayActivity" @toUpdate="toUpdate"></c-activity-manage-list>
			</scroll-view>
		</view>
		<!-- 待审核活动 -->
		<view style="width: 95%;margin: 20rpx auto;height: 500rpx;background-color: #FFFFFF;border-radius: 20rpx;">
			<view>
				<view
					style="color: blue;font-size: 36rpx;font-weight: 900;border-bottom: 1rpx solid blue;width: 180rpx;padding-bottom: 10rpx;padding: 20rpx;">
					待审核
				</view>
			</view>
			<scroll-view scroll-y style="height: 400rpx;">
				<c-activity-manage-list @updateOk="updateOk" :nowStatus="2" :data="noShenActivity" @toUpdate="toUpdate"></c-activity-manage-list>
			</scroll-view>
		</view>
		<!-- 已结束活动 -->
		<view style="width: 95%;margin: 20rpx auto;height: 500rpx;background-color: #FFFFFF;border-radius: 20rpx;">
			<view>
				<view
					style="font-size: 36rpx;font-weight: 900;border-bottom: 1rpx solid #FEDE33;width: 180rpx;padding-bottom: 10rpx;padding: 20rpx;">
					已结束
				</view>
			</view>
			<scroll-view scroll-y style="height: 400rpx;">
				<c-activity-manage-list @updateOk="updateOk" :nowStatus="3" :data="noUnderwayActivity"></c-activity-manage-list>
			</scroll-view>
		</view>
		<!-- 审核失败活动 -->
		<view style="width: 95%;margin: 20rpx auto;height: 500rpx;background-color: #FFFFFF;border-radius: 20rpx;">
			<view>
				<view
					style="color: red;font-size: 36rpx;font-weight: 900;border-bottom: 1rpx solid red;width: 180rpx;padding-bottom: 10rpx;padding: 20rpx;">
					审核失败
				</view>
			</view>
			<scroll-view scroll-y style="height: 400rpx;">
				<c-activity-manage-list @updateOk="updateOk" :nowStatus="4" :data="failActivity" @toUpdate="toUpdate"></c-activity-manage-list>
			</scroll-view>
		</view>
		<!-- 全部活动 -->
		<view style="width: 95%;margin: 20rpx auto;height: 500rpx;background-color: #FFFFFF;border-radius: 20rpx;">
			<view>
				<view style="color:#FEDE33;font-size: 36rpx;font-weight: 900;border-bottom: 1rpx solid #FEDE33;width: 180rpx;padding-bottom: 10rpx;padding: 20rpx;">
					全部活动
				</view>
			</view>
			<scroll-view scroll-y style="height: 400rpx;">
				<c-activity-manage-list @updateOk="updateOk" :nowStatus="5" :data="allActivity"></c-activity-manage-list>
			</scroll-view>
		</view>
		<!-- 发布活动 -->
		<!--  @click="toRelease" -->
		<view @click="showAddActivity=true" style="position: fixed;right: 50rpx;bottom: 200rpx;border-radius: 20rpx;border: 1rpx solid #000000;background-color: #55ff00;padding: 20rpx;">
			发布活动
		</view>
		<u-mask :show="showAddActivity" :zoom="true" :duration="300">
			<scroll-view scroll-y style="background-color: #FFFFFF;" :style="{height:swiperHeight-40+'px'}">
				<view class="warp">
					<c-add-activity :nowUserClub="nowUserClub" :updateActivity="updateActivity" @updateOk="updateOk"></c-add-activity>
				</view>
			</scroll-view>
		</u-mask>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import cActivityManageList from "./c-activity-manage-list.vue";
	import cAddActivity from "./c-add-activity.vue";
	export default {
		components: {cActivityManageList,cAddActivity},
		props:["nowUserClub"],
		computed: mapState(['isLogin', 'loginUserInfo']),
		data() {
			return {
				userClub: null,
				allActivity:[],
				noShenActivity:[],
				underwayActivity:[],
				noUnderwayActivity:[],
				failActivity:[],
				
				showAddActivity:false,
				updateActivity:{
					title: "",
					subTitle: "",
					image: null,
					detail: "",
					clubId: "",
					clubName: "",
					joinmax: "",
					createTime: "",
					endTime: "",
					contact: ""
				},
				caozuo:null,
			}
		},
		created(){
			this.loadAllActivity()
		},
		methods: {
			loadAllActivity(){
				uni.request({
					url: this.url.movement.getOneClubAllActivity + "/" + this.nowUserClub.clubId,
					method: 'GET',
					header: {},
					success: (res) => {
						this.allActivity = res.data.allActivity
						// console.log("AllActivity",res)
					},
					fail: (res) => {
						console.log("失败 -- 得到当前社团成员", res)
					}
				});
				uni.request({
					url: this.url.movement.getOneClubUnderwayActivity + "/" + this.nowUserClub.clubId,
					method: 'GET',
					header: {},
					success: (res) => {
						this.underwayActivity = res.data.underwayActivity
						// console.log("underwayActivity",res)
					},
					fail: (res) => {
						console.log("失败 -- 得到正在进行的活动", res)
					}
				});
				uni.request({
					url: this.url.movement.getOneClubNoUnderwayActivity + "/" + this.nowUserClub.clubId,
					method: 'GET',
					header: {},
					success: (res) => {
						this.noUnderwayActivity = res.data.noUnderwayActivity
						// console.log("noUnderwayActivity",res)
					},
					fail: (res) => {
						console.log("失败 -- 得到已结束的活动", res)
					}
				});
				uni.request({
					url: this.url.movement.getOneClubAllActivity + "/" + this.nowUserClub.clubId+ "/0",
					method: 'GET',
					header: {},
					success: (res) => {
						this.noShenActivity = res.data.allActivity
						// console.log("noShenActivity",res)
					},
					fail: (res) => {
						console.log("失败 -- 得到未审核noShenActivity", res)
					}
				});
				uni.request({
					url: this.url.movement.getOneClubAllActivity + "/" + this.nowUserClub.clubId+ "/2",
					method: 'GET',
					header: {},
					success: (res) => {
						this.failActivity = res.data.allActivity
						// console.log("failActivity",res)
					},
					fail: (res) => {
						console.log("失败 -- 得到审核失败failActivity", res)
					}
				});
			},
			
			toUpdate(item){
				//item：修改的对象
				this.updateActivity = item;
				this.showAddActivity = true;
				console.log(this.updateActivity)
			},
			
			updateOk(){
				this.updateActivity = {
					title: "",
					subTitle: "",
					image: null,
					detail: "",
					clubId: "",
					clubName: "",
					joinmax: "",
					createTime: "",
					endTime: "",
					contact: ""
				}
				this.showAddActivity = false;
				this.loadAllActivity()
			},
		}
	}
</script>

<style>

</style>
